<table id="tableCustStockAlert">
    <thead class="center bold">
        <tr>
            <td rowspan="2">&nbsp;</td>
            <td colspan="3">Num. of Products</td>
        </tr>
        <tr>
            <td><= Min</td>
            <td>< Max</td>
            <td>> Max</td>
        </tr>
    </thead>
    <tbody>
        <?php foreach ($this->data as $customer) : ?>
        <?php if ($customer['0']['site_null'] == true) : ?>
                <tr class="bold even-cell">
                    <td class="<?php echo empty($customer['Row']['cust_name']) ? 'text-right' : ''; ?>"><?php echo empty($customer['Row']['cust_name']) ? 'Grand Total' : $customer['Row']['cust_name']; ?></td>
                    <td class="text-right "><?php echo $customer['Row']['num_red']; ?></td>
                    <td class="text-right "><?php echo $customer['Row']['num_yellow']; ?></td>
                    <td class="text-right "><?php echo $customer['Row']['num_green']; ?></td>
                </tr>
        <?php elseif ($customer['0']['cust_null'] == false && $customer['0']['site_null'] == false) : ?>
                    <tr class="odd-cell">
                        <td style="text-indent: 5pt;">
                <?php echo $html->link($customer['Row']['site_name'],
                            '/users/popup_cust_inventories/' . $customer['Row']['site_id'], array('onclick' => 'return false;')); ?>
                </td>
                <td class="text-right min-stock"><?php echo $customer['Row']['num_red']; ?></td>
                <td class="text-right max-stock"><?php echo $customer['Row']['num_yellow']; ?></td>
                <td class="text-right green"><?php echo $customer['Row']['num_green']; ?></td>
            </tr>
        <?php endif; ?>
        <?php endforeach; ?>
                </tbody>
            </table>
            <div class="caption">
                Number of Products that<br />
                <span class="min-stock rect"></span> Current Stock is less than or equal Min Stock.<br />
                <span class="max-stock rect"></span> Current Stock is less than Max Stock.<br />
                <span class="green rect"></span> Current Stock is higher than Max Stock.<br />
            </div>
            <script type="text/javascript">
                $j(function() {
                    $j('#tableCustStockAlert tr.odd-cell a').popup();


                    // ดักจับ event คลิกที่แถว แล้วคลิกที่ชื่อ site ต่อให้เลย
                    $j('#tableCustStockAlert tr.odd-cell').hightlight().handover().bind('click', function(e) {
                        if (e.target.tagName != 'A') {
                            $j('a', this).trigger('click');

                        }
                    })
                });
            </script>

<?php //debug($this->data); ?>